<template>
  <div style="padding-bottom: 35px;">
    <div v-for="(item,index) in workList" :key="index" class="demand-content">
      <div class="demand-top">
        <div class="top-left">
          <div>{{ item.bugName }}</div>
          <div v-if="item.bugStatus==='wait'">
            未开始
          </div>
          <div v-else-if="item.bugStatus==='doing'">
            进行中
          </div>
          <div v-else-if="item.bugStatus==='suspend'">
            已挂起
          </div>
          <div v-else>
            已关闭
          </div>
        </div>
        <div class="top-right">
          <img src="../../../../static/project/cz.png" alt="" @click="detailBug(item)" />
          <img src="../../../../static/project/five.png" alt="" @click="bugClick(item.id)" />
        </div>
      </div>
      <div class="demand-time">
        <div>{{ item.createTime | timeFormat }}</div>
      </div>
      <div class="demand-more">
        <div>负责人</div>
        <div>{{ item.name }}</div>
      </div>
      <div class="demand-more">
        <div>bug来源</div>
        <div>{{ item.bugSource=='1'?'主线任务':'支线任务' }}</div>
      </div>
      <div class="demand-more">
        <div>bug类型</div>
        <div>{{ item.bugType=='1'?'系统优化':'功能问题' }}</div>
      </div>
    </div>
    <uni-load-more class="task-more" :status="loadMoreStatus" />
  </div>
</template>

<script>
import { formatTimestamp } from '@/utils/format'
import { showConfirm } from '@/utils/common'
import { deleteBugTask } from '@/apis/project'
export default {
  filters: {
    timeFormat(value) {
      const time = new Date(value).getTime()
      return formatTimestamp(time)
    },
  },
  props: {
    workList: {
      type: Array,
    },
    loadMoreStatus: {
      type: String,
    },
  },
  methods: {
    detailBug(item) {
      uni.navigateTo({
        url: `/pages/index/tabs/work/bug-detail?param=${encodeURIComponent(JSON.stringify(item))}`,
      })
    },
    // 删除按钮点击
    bugClick(id) {
      showConfirm('确认删除该任务?').then(() => {
        this.delteBugFunc(id)
      })
    },
    async delteBugFunc(id) {
      const res = await deleteBugTask(id)
      if (res) {
        this.$emit('getTaskBugList')
        uni.showToast({
          title: '删除成功!',
          icon: 'success',
          duration: 1700,
        })
      }
    },
  },
}
</script>
<style lang="scss" scoped>
	.demand-content{
		width:93%;
		margin:0 auto;
		box-shadow: 0px 0px 4px 0px rgba(0,0,0,0.06);
		border-radius: 2px;
		padding-bottom: 1px;
		margin-bottom: 10px;
		.demand-top{
			padding: 15px 10px 0px 10px;
			display: flex;
			justify-content: space-between;
			margin-bottom: 10px;
			.top-left{
				display: flex;
				div:nth-child(1){
					font-size: 16px;
					color:#333;
					font-weight: 600;
					margin-right: 15px;
				}
				div:nth-child(2){
					background: rgba(115,158,202,0.1);
					border-radius: 2px;
					border: 1px solid #739ECA;
					color: #739ECA;
					font-size: 14px;
					padding: 0px 5px;
				}
			}
			.top-right{
				display: flex;
				align-items: center;
				van-icon{
					color:#739ECA;
				}
				img{
					width:16px;
					height:16px;
				}
			}
		}
		.demand-more{
			margin-bottom: 10px;
			padding: 0px 10px 0px 10px;
			display: flex;
			justify-content: space-between;
		}
		.demand-time{
			padding: 0px 10px 0px 10px;
			font-size: 12px;
			margin-bottom: 10px;
		}
	}
</style>
<style lang="scss">
	.task-more{
		::v-deep view{
			height:55px !important;
			text{
				height:100%;
			}
		}
	}
</style>
